package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
@ToString
public class BuyRecord {
    private Long id;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date inputTime;
    private Customer customer;
    private Product product;

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("inputTime", inputTime);
        map.put("customerId", customer.getId());
        map.put("customerName", customer.getName());
        map.put("product", product);

        return JSON.toJSONString(map);
    }

}